Skip to content

apt_dpkg: discard cached contents mapping on OSError#593

Open
bdrung wants to merge 1 commit intocanonical:mainfrom
bdrung:fix-pickle-load
Open

apt_dpkg: discard cached contents mapping on OSError#593
bdrung wants to merge 1 commit intocanonical:mainfrom
bdrung:fix-pickle-load

Conversation

@bdrung
Copy link
Copy Markdown
Member

@bdrung bdrung commented Apr 22, 2026

test_retrace_jammy_sandbox might fail in a autopkgtest VM:

Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 713, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/bin/apport-retrace", line 542, in main
    sandbox, cache, outdated_msg = apport.sandboxutils.make_sandbox(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        report,
        ^^^^^^^
    ...<6 lines>...
        options.dynamic_origins,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 274, in make_sandbox
    pkgs = needed_runtime_packages(report, pkgmap_cache_dir, pkg_versions, verbose)
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 103, in needed_runtime_packages
    pkg = packaging.get_file_package(
        line,
    ...<3 lines>...
        arch=report.get("Architecture"),
    )
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 800, in get_file_package
    return self._search_contents(file, map_cachedir, release, arch)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1752, in _search_contents
    contents_mapping = self._get_file2pkg_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1726, in _get_file2pkg_mapping
    file2pkg = self._contents_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 340, in _contents_mapping
    self._contents_mapping_obj = pickle.load(fp)
                                 ~~~~~~~~~~~^^^^
EOFError: Ran out of input

Discard the cache in those cases and just rebuild them.

Bug: https://launchpad.net/bugs/2149911

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.47%. Comparing base (5beb93d) to head (97ccb24).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
+ Coverage   84.45%   84.47%   +0.02%     
==========================================
  Files         104      104              
  Lines       20939    20967      +28     
  Branches     3212     3216       +4     
==========================================
+ Hits        17683    17711      +28     
- Misses       2815     2816       +1     
+ Partials      441      440       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdrung bdrung force-pushed the fix-pickle-load branch 2 times, most recently from 9f689b8 to 18f5f37 Compare April 22, 2026 18:29
test_retrace_jammy_sandbox might fail in a autopkgtest VM:

```
Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 713, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/bin/apport-retrace", line 542, in main
    sandbox, cache, outdated_msg = apport.sandboxutils.make_sandbox(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        report,
        ^^^^^^^
    ...<6 lines>...
        options.dynamic_origins,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 274, in make_sandbox
    pkgs = needed_runtime_packages(report, pkgmap_cache_dir, pkg_versions, verbose)
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 103, in needed_runtime_packages
    pkg = packaging.get_file_package(
        line,
    ...<3 lines>...
        arch=report.get("Architecture"),
    )
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 800, in get_file_package
    return self._search_contents(file, map_cachedir, release, arch)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1752, in _search_contents
    contents_mapping = self._get_file2pkg_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1726, in _get_file2pkg_mapping
    file2pkg = self._contents_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 340, in _contents_mapping
    self._contents_mapping_obj = pickle.load(fp)
                                 ~~~~~~~~~~~^^^^
EOFError: Ran out of input
```

Discard the cache in those cases and just rebuild them.

Bug: https://launchpad.net/bugs/2149911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant